package me.zhengjie.modules.insurance.mapper;

import me.zhengjie.modules.insurance.domain.InsuredApplyConnectRecord;
import me.zhengjie.modules.insurance.pojo.InsuredApplyConnectRecordResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface InsuredApplyConnectRecordMapper {
    int deleteByPrimaryKey(Long id);

    int insert(InsuredApplyConnectRecord record);

    int insertSelective(InsuredApplyConnectRecord record);

    InsuredApplyConnectRecord selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(InsuredApplyConnectRecord record);

    int updateByPrimaryKey(InsuredApplyConnectRecord record);

    /**
     * 找到应用沟通记录
     *
     * @param applyId 应用id
     * @return {@link List}<{@link InsuredApplyConnectRecordResponse}>
     */
    List<InsuredApplyConnectRecordResponse> findApplyConnectRecord(@Param("applyId") long applyId);

    /**
     * 找到案件申请最后下次沟通时间
     *
     * @param applyIds 应用id
     * @return {@link List}<{@link InsuredApplyConnectRecord}>
     */
    List<InsuredApplyConnectRecord> findApplyLastConnectTime(@Param("applyIds") List<Long> applyIds);

    /**
     * 统计当前用户 指定时间内人沟通案件数
     *
     * @param start         开始
     * @param end           结束
     * @param currentUserId 当前用户id
     * @return {@link Integer}
     */
    Integer countNextTime(@Param("start") Date start, @Param("end") Date end, @Param("currentUserId") long currentUserId);

    /**
     * 获取案件最后记录
     *
     * @param id id
     * @return {@link InsuredApplyConnectRecord}
     */
    InsuredApplyConnectRecord getApplyLast(@Param("applyId") long applyId);
}